from manimlib import *


class BoolVGroup(VMobject):
    def __init__(self, *vmobject,**kwargs):
        if not all([isinstance(m, VMobject) for m in vmobject]):
            raise Exception("All submobjects must be of type VMobject")
        super().__init__(**kwargs)
        # self.add(*vmobjects)
        # for obj in vmobject:
        #     self.append_points(obj.get_all_points())
        # pnts = np.array([[0,0,0]])
        for index, obj in enumerate(vmobject):
            if index % 2:
                self.append_points(obj.get_all_points()[::-1])
            else:
                self.append_points(obj.get_all_points())
        # pnts = pnts[1:]
        # print(pnts)
        # self.set_points(pnts)
        


class TextBool(Scene):
    def construct(self):
        cir = Rectangle()
        text = TexText("Hello").scale(5)
        bg = BoolVGroup(cir, text)
        bg.set_stroke(width=0)
        bg.set_fill(opacity=0.2)
        self.add(bg)
        # vm = VMobject()
        # vm.set_points(np.array([[-4,-1,0],[1,-2,0],[5,3,0]]))
        # self.add(vm)